<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\api\model;

use think\Model;

class UserMenuModel extends Model
{
    // 确定链接表名
    protected $table = 'xl_user_menu';


   
   public function getUserMenu($where){
      return $this->where($where)->select();

   }
    /**
     * 添加关注
     * @param $param
     */
    public function insertMenu($param)
    {
        try{
              $data=$this->getOneOrder('*',array('order_no'=>$param['order_no']));
              if(empty($data)){

                   // $param['add_time']=time();
                    $result =  $this->save($param);
                    if(false === $result){
                        // 验证失败 输出错误信息
                        return array('code'=>-1,'url'=>'', 'msg'=>$this->getError());
                    }else{

                        return array('code'=>1, 'url'=>'', 'msg'=>'订单添加成功');
                    }
              }
          
        }catch(PDOException $e){

            return array('code'=>-2, 'url'=>'', 'msg'=>$e->getMessage());
        }
    }

    public function getOneOrder($field,$where)
    {

        return $this->field($field)->where($where)->find();
    }

    public function deleteConcern($where){
       
         try{

           $result=$this->where($where)->delete();
            if(false === $result){
                // 验证失败 输出错误信息
                return array('code'=>-1,'url'=>'', 'msg'=>$this->getError());
            }else{

                return array('code'=>1, 'url'=>'', 'msg'=>'取消成功');
            }
        }catch(PDOException $e){

            return array('code'=>-2, 'url'=>'', 'msg'=>$e->getMessage());
        }
      }
}

